} else
dom->use_consolepath = 0;
- sprintf(path, "%s/type", dom->use_consolepath ? dom->conspath: dom->serialpath);
+ snprintf(path, sizeof(path), "%s/type",
+ dom->use_consolepath ? dom->conspath: dom->serialpath);
type = xs_read(xs, XBT_NULL, path, NULL);
if (type && strcmp(type, "xenconsoled") != 0) {
free(type);
printf("File open issued for %s\n", file_name);
assert(BUFFER_SIZE >
strlen(file_name) + strlen(mount->export->export_path) + 1);
- sprintf(full_path, "%s/%s", mount->export->export_path, file_name);
+ snprintf(full_path, sizeof(full_path), "%s/%s",
+ mount->export->export_path, file_name);
assert(xc_gnttab_munmap(mount->gnth, file_name, 1) == 0);
printf("Issuing open for %s\n", full_path);
fd = open(full_path, O_RDWR);
printf("File remove issued for %s\n", file_name);
assert(BUFFER_SIZE >
strlen(file_name) + strlen(mount->export->export_path) + 1);
- sprintf(full_path, "%s/%s", mount->export->export_path, file_name);
+ snprintf(full_path, sizeof(full_path), "%s/%s",
+ mount->export->export_path, file_name);
assert(xc_gnttab_munmap(mount->gnth, file_name, 1) == 0);
printf("Issuing remove for %s\n", full_path);
ret = remove(full_path);
strlen(old_file_name) + strlen(mount->export->export_path) + 1);
assert(BUFFER_SIZE >
strlen(new_file_name) + strlen(mount->export->export_path) + 1);
- sprintf(old_full_path, "%s/%s", mount->export->export_path, old_file_name);
- sprintf(new_full_path, "%s/%s", mount->export->export_path, new_file_name);
+ snprintf(old_full_path, sizeof(old_full_path), "%s/%s",
+ mount->export->export_path, old_file_name);
+ snprintf(new_full_path, sizeof(new_full_path), "%s/%s",
+ mount->export->export_path, new_file_name);
assert(xc_gnttab_munmap(mount->gnth, buf, 1) == 0);
printf("Issuing rename for %s -> %s\n", old_full_path, new_full_path);
ret = rename(old_full_path, new_full_path);
printf("File create issued for %s\n", file_name);
assert(BUFFER_SIZE >
strlen(file_name) + strlen(mount->export->export_path) + 1);
- sprintf(full_path, "%s/%s", mount->export->export_path, file_name);
+ snprintf(full_path, sizeof(full_path), "%s/%s",
+ mount->export->export_path, file_name);
assert(xc_gnttab_munmap(mount->gnth, file_name, 1) == 0);
/* We can advance the request consumer index, from here on, the request
* should not be used (it may be overrinden by a response) */
printf("Dir list issued for %s\n", file_name);
assert(BUFFER_SIZE >
strlen(file_name) + strlen(mount->export->export_path) + 1);
- sprintf(full_path, "%s/%s", mount->export->export_path, file_name);
+ snprintf(full_path, sizeof(full_path), "%s/%s",
+ mount->export->export_path, file_name);
/* We can advance the request consumer index, from here on, the request
* should not be used (it may be overrinden by a response) */
mount->ring.req_cons++;
printf("Fs space issued for %s\n", file_name);
assert(BUFFER_SIZE >
strlen(file_name) + strlen(mount->export->export_path) + 1);
- sprintf(full_path, "%s/%s", mount->export->export_path, file_name);
+ snprintf(full_path, sizeof(full_path), "%s/%s",
+ mount->export->export_path, file_name);
assert(xc_gnttab_munmap(mount->gnth, file_name, 1) == 0);
printf("Issuing fs space for %s\n", full_path);
ret = statfs(full_path, &stat);
va_list args;
va_start(args, fmt);
- sprintf(fullpath,"%s/%s", node, path);
- vsprintf(val, fmt, args);
+ snprintf(fullpath, sizeof(fullpath), "%s/%s", node, path);
+ vsnprintf(val, sizeof(val), fmt, args);
va_end(args);
printf("xenbus_printf (%s) <= %s.\n", fullpath, val);
printf("XS transaction is %d\n", xst);
/* Create node string */
- sprintf(node, "%s/%d", EXPORTS_NODE, export->export_id);
+ snprintf(node, sizeof(node), "%s/%d", EXPORTS_NODE, export->export_id);
/* Remove old export (if exists) */
xs_rm(xsh, xst, node);
assert(xsh != NULL);
#if 0
- sprintf(node, WATCH_NODE"/%d/%d/frontend",
+ snprintf(node, sizeof(node), WATCH_NODE"/%d/%d/frontend",
mount->dom_id, mount->export->export_id);
frontend = xs_read(xsh, XBT_NULL, node, NULL);
#endif
mount->frontend = frontend;
- sprintf(node, "%s/state", frontend);
+ snprintf(node, sizeof(node), "%s/state", frontend);
s = xs_read(xsh, XBT_NULL, node, NULL);
assert(strcmp(s, STATE_READY) == 0);
free(s);
- sprintf(node, "%s/ring-ref", frontend);
+ snprintf(node, sizeof(node), "%s/ring-ref", frontend);
s = xs_read(xsh, XBT_NULL, node, NULL);
mount->gref = atoi(s);
free(s);
- sprintf(node, "%s/event-channel", frontend);
+ snprintf(node, sizeof(node), "%s/event-channel", frontend);
s = xs_read(xsh, XBT_NULL, node, NULL);
mount->remote_evtchn = atoi(s);
free(s);
assert(xsh != NULL);
self_id = get_self_id();
printf("Our own dom_id=%d\n", self_id);
- sprintf(node, "%s/backend", mount->frontend);
- sprintf(backend_node, "/local/domain/%d/"ROOT_NODE"/%d",
+ snprintf(node, sizeof(node), "%s/backend", mount->frontend);
+ snprintf(backend_node, sizeof(backend_node), "/local/domain/%d/"ROOT_NODE"/%d",
self_id, mount->mount_id);
xs_write(xsh, XBT_NULL, node, backend_node, strlen(backend_node));
- sprintf(node, ROOT_NODE"/%d/state", mount->mount_id);
+ snprintf(node, sizeof(node), ROOT_NODE"/%d/state", mount->mount_id);
xs_write(xsh, XBT_NULL, node, STATE_INITIALISED, strlen(STATE_INITIALISED));
}
assert(xsh != NULL);
self_id = get_self_id();
- sprintf(node, ROOT_NODE"/%d/state", mount->mount_id);
+ snprintf(node, sizeof(node), ROOT_NODE"/%d/state", mount->mount_id);
xs_write(xsh, XBT_NULL, node, STATE_READY, strlen(STATE_READY));
}
char zfs_bootstr[] = "zfs-bootfs=";
char zfs_bootpath[] = ",bootpath='";
- sprintf(temp, "%llu", (unsigned long long)
+ snprintf(temp, sizeof(temp), "%llu", (unsigned long long)
current_bootfs_obj);
alloc_size = strlen(zfs_bootstr) +
strlen(current_rootpool) +
xc_dom_printf("%s: called\n", __FUNCTION__);
memset(start_info, 0, sizeof(*start_info));
- sprintf(start_info->magic, dom->guest_type);
+ snprintf(start_info->magic, sizeof(start_info->magic), dom->guest_type);
start_info->nr_pages = dom->total_pages;
start_info->shared_info = shinfo << PAGE_SHIFT_X86;
start_info->pt_base = dom->pgtables_seg.vstart;
xc_dom_printf("%s: called\n", __FUNCTION__);
memset(start_info, 0, sizeof(*start_info));
- sprintf(start_info->magic, dom->guest_type);
+ snprintf(start_info->magic, sizeof(start_info->magic), dom->guest_type);
start_info->nr_pages = dom->total_pages;
start_info->shared_info = shinfo << PAGE_SHIFT_X86;
start_info->pt_base = dom->pgtables_seg.vstart;
/* XXX This is a bit dubious, but there is no vsyslog */
va_start(ap, format);
- vsprintf(logbuf, format, ap);
+ vsnprintf(logbuf, sizeof(logbuf), format, ap);
syslog(LOG_ERR, logbuf);
va_end(ap);
exit(1);
strncpy(hypercall_name, hypercall_name_table[j],
sizeof(hypercall_name));
else
- sprintf(hypercall_name, "[%d]", j);
+ snprintf(hypercall_name, sizeof(hypercall_name), "[%d]", j);
hypercall_name[sizeof(hypercall_name)-1]='\0';
printf("%-35s ", hypercall_name);
printf("%12u\n", (unsigned int)val[j]);
switch(addr->family){
default:
case AF_INET:
- sprintf(buf, "%u.%u.%u.%u",
+ snprintf(buf, sizeof(buf), "%u.%u.%u.%u",
NIPQUAD(addr->u.ip4));
break;
case AF_INET6:
- sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
+ snprintf(buf, sizeof(buf), "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
NIP6(addr->u.ip6));
break;
}
static inline const char *VnetId_ntoa(VnetId *vnet, char buf[VNET_ID_BUF])
{
- sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
+ snprintf(buf, sizeof(buf), "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
ntohs(vnet->u.vnet16[0]), \
ntohs(vnet->u.vnet16[1]), \
ntohs(vnet->u.vnet16[2]), \
if(err) break;
vnetid = VNET_VIF + i;
vnet->vnet = toVnetId(vnetid);
- sprintf(vnet->device, "vnif%04x", vnetid);
+ snprintf(vnet->device, sizeof(vnet->device), "vnif%04x", vnetid);
vnet->security = (vnetid > 10 ? security : 0);
err = Vnet_create(vnet);
Vnet_decref(vnet);
// This must be updated to the longest command name. Currently GETINST
#define VTPM_SH_CMD_SIZE (strlen(VTPM_SH_CMD_HDR) + strlen(VTPM_SH_CMD_FTR) + 1 + strlen(VTPM_SH_GETINST) + 2)
-void handle_vtpm_mig_step2(buffer_t *in_param_buf, buffer_t *result_buf){
-
+void handle_vtpm_mig_step2(buffer_t *in_param_buf, buffer_t *result_buf)
+{
TPM_TAG tag = VTPM_TAG_RSP;
buffer_t out_param_buf= NULL_BUF, mig_key_buf=NULL_BUF;
TPM_RESULT status=TPM_SUCCESS, cmd_status;
return;
}
-void handle_vtpm_mig_step3(buffer_t *in_param_buf, buffer_t *result_buf){
-
+void handle_vtpm_mig_step3(buffer_t *in_param_buf, buffer_t *result_buf)
+{
TPM_TAG tag = VTPM_TAG_RSP;
buffer_t out_param_buf= NULL_BUF, mig_key_buf=NULL_BUF, empty_buf=NULL_BUF;
TPM_RESULT status=TPM_SUCCESS, cmd_status;
UINT32 out_param_size, instance;
char *shell_cmd_str=NULL;
+ size_t shell_cmd_strlen;
FILE *shell_f=NULL;
if ( (!in_param_buf) || (!result_buf) ) {
}
// ====== Call hotplug-script and get an instance ======
- shell_cmd_str = (char *) malloc(VTPM_SH_CMD_SIZE + name_data32.size + 10); // 10 is just padding for the UINT32
+ shell_cmd_strlen = VTPM_SH_CMD_SIZE + name_data32.size + 10;
+ shell_cmd_str = (char *) malloc(shell_cmd_strlen); // 10 is just padding for the UINT32
- sprintf(shell_cmd_str, VTPM_SH_CMD_HDR VTPM_SH_GETINST VTPM_SH_CMD_FTR);
+ snprintf(shell_cmd_str, shell_cmd_strlen,
+ VTPM_SH_CMD_HDR VTPM_SH_GETINST VTPM_SH_CMD_FTR);
shell_f = popen(shell_cmd_str, "r");
fscanf(shell_f, "%d", &instance);
pclose(shell_f);
// ====== Call hotplug-script and add instance ======
- sprintf(shell_cmd_str, VTPM_SH_CMD_HDR VTPM_SH_ADD " %s %d" VTPM_SH_CMD_FTR, name_data32.data, instance);
+ snprintf(shell_cmd_str, shell_cmd_strlen,
+ VTPM_SH_CMD_HDR VTPM_SH_ADD " %s %d" VTPM_SH_CMD_FTR,
+ name_data32.data, instance);
system(shell_cmd_str);
// ========= Call vtpm_manager and load VTPM =======
TPMTRYRETURN(cmd_status);
// ====== Call hotplug-script and resume instance ======
- sprintf(shell_cmd_str, VTPM_SH_CMD_HDR VTPM_SH_RESUME " %d" VTPM_SH_CMD_FTR, instance);
+ snprintf(shell_cmd_str, shell_cmd_strlen,
+ VTPM_SH_CMD_HDR VTPM_SH_RESUME " %d" VTPM_SH_CMD_FTR, instance);
system(shell_cmd_str);
goto egress;
new_qos->domain_info[idx].blocked_start_time = 0;
new_qos->domain_info[idx].id = domid;
if (domid == IDLE_DOMAIN_ID)
- sprintf(new_qos->domain_info[idx].name, "Idle Task%d", global_cpu);
+ snprintf(new_qos->domain_info[idx].name,
+ sizeof(new_qos->domain_info[idx].name),
+ "Idle Task%d", global_cpu);
else
- sprintf(new_qos->domain_info[idx].name, "Domain#%d", domid);
+ snprintf(new_qos->domain_info[idx].name,
+ sizeof(new_qos->domain_info[idx].name),
+ "Domain#%d", domid);
for (i=0; i<NSAMPLES; i++) {
new_qos->qdata[i].ns_gotten[idx] = 0;